package Bean;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.Serializable;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import org.primefaces.model.map.DefaultMapModel;
import org.primefaces.model.map.LatLng;
import org.primefaces.model.map.MapModel;
import org.primefaces.model.map.Marker;

/**
 *
 * @author Toshiba
 */
@ManagedBean
@RequestScoped

public class MapBean implements Serializable {

	private MapModel emptyModel;
	
	private String title;
        private String longitude2 ="";
         private String longitude ="";
          private String latitude ="";
           private String latitude2 ="";
            private String altura =" 800 KM";
             private String altura2 =" 750 KM";
	private double lat;
	
	private double lng;

	public MapBean() {
		emptyModel = new DefaultMapModel();
	}
	
	public MapModel getEmptyModel() {
		return emptyModel;
	}
	
	public void addMessage(FacesMessage message) {
		FacesContext.getCurrentInstance().addMessage(null, message);
	}
	
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public double getLat() {
		return lat;
	}

	public void setLat(double lat) {
		this.lat = lat;
	}

	public double getLng() {
		return lng;
	}

	public void setLng(double lng) {
		this.lng = lng;
	}
	
	public void addMarker(ActionEvent actionEvent) {
		Marker marker = new Marker(new LatLng(lat, lng), title);
		emptyModel.addOverlay(marker);
		
		addMessage(new FacesMessage(FacesMessage.SEVERITY_INFO, "Marcador Adicionado", "Local Selecionado com Sucesso"));
	}

    /**
     * @return the longitude2
     */
    public String getLongitude2() {
        return longitude2;
    }

    /**
     * @param longitude2 the longitude2 to set
     */
    public void setLongitude2(String longitude2) {
        this.longitude2 = longitude2;
    }

    /**
     * @return the longitude
     */
    public String getLongitude() {
        return longitude;
    }

    /**
     * @param longitude the longitude to set
     */
    public void setLongitude(String longitude) {
        this.longitude = longitude;
    }

    /**
     * @return the latitude
     */
    public String getLatitude() {
        return latitude;
    }

    /**
     * @param latitude the latitude to set
     */
    public void setLatitude(String latitude) {
        this.latitude = latitude;
    }

    /**
     * @return the latitude2
     */
    public String getLatitude2() {
        return latitude2;
    }

    /**
     * @param latitude2 the latitude2 to set
     */
    public void setLatitude2(String latitude2) {
        this.latitude2 = latitude2;
    }

    /**
     * @return the altura
     */
    public String getAltura() {
        return altura;
    }

    /**
     * @param altura the altura to set
     */
    public void setAltura(String altura) {
        this.altura = altura;
    }

    /**
     * @return the altura2
     */
    public String getAltura2() {
        return altura2;
    }

    /**
     * @param altura2 the altura2 to set
     */
    public void setAltura2(String altura2) {
        this.altura2 = altura2;
    }
        
}
        
        
        
      

   

